package jmine.tec.services.runner;

import java.math.BigDecimal;

import jmine.tec.services.api.ActionsEnum;
import jmine.tec.services.export.impl.ExportUtils;
import jmine.tec.services.io.ServiceBean;
import jmine.tec.test.Builder;
import bancosys.tec.persist.base.enumx.IntValuedEnum;
import bancosys.tec.persist.base.enumx.StringValuedEnum;
import bancosys.tec.utils.date.Date;

/**
 * Builder base para demais builders de serviços.
 * 
 * @author lundberg
 */
public class BaseServiceBuilder implements Builder<ServiceBean> {

    private ServiceBean bean = new ServiceBean();

    public BaseServiceBuilder() {
    }

    public BaseServiceBuilder(Class<?> serviceClass) {
        this(ExportUtils.getServiceAction(serviceClass), ExportUtils.getServiceName(serviceClass));
    }

    public BaseServiceBuilder(ActionsEnum action, String name) {
        this.bean.setAction(action);
        this.bean.setName(name);
    }

    public BaseServiceBuilder with(String key, String value) {
        ExportUtils.put(this.bean, key, value);
        return this;
    }

    public BaseServiceBuilder with(String key, Date value) {
        ExportUtils.put(this.bean, key, value);
        return this;
    }

    public BaseServiceBuilder with(String key, BigDecimal value) {
        ExportUtils.put(this.bean, key, value);
        return this;
    }

    public BaseServiceBuilder with(String key, Enum<?> value) {
        ExportUtils.put(this.bean, key, value);
        return this;
    }

    public BaseServiceBuilder with(String key, StringValuedEnum value) {
        ExportUtils.put(this.bean, key, value);
        return this;
    }

    public BaseServiceBuilder with(String key, IntValuedEnum value) {
        ExportUtils.put(this.bean, key, value);
        return this;
    }

    public BaseServiceBuilder with(String key, Object value) {
        ExportUtils.put(this.bean, key, value);
        return this;
    }

    public ServiceBean build() {
        return this.bean;
    }
}
